<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="店铺盈利">

<style>
    .form-horizontal .controls {
        line-height: 40px;
        height: 40px;
        margin-left: 3px;
    }

</style>
<!--suppress ALL -->
<form id="searchForm" class="form-panel" action="${basepath}/rest/manage/brokerage/loadData">
    <ul class="panel-content ">
        <li>
            <div class="control-group span5">
                <div class="controls">
                    <input type="text" id="nickname" name="nickname" placeholder="输入关键字搜索"/>
                </div>
            </div>
            <div class="form-actions span3">
                <button type="submit" class="button  button-primary">
                    查询
                </button>
            </div>
        </li>
    </ul>
</form>
<div id="grid"></div>
<script>
    var Grid = BUI.Grid,
            Store = BUI.Data.Store,
            columns = [
                {title: 'id', dataIndex: 'id', elCls: 'center', width: '5%'},
                {title: '用户昵称', dataIndex: 'nickname', elCls: 'center', width: '20%'},
                {
                    title: '购买或升级',
                    dataIndex: 'status',
                    elCls: 'center',
                    width: '20%',
                    renderer: function (value) {
                        if (value == "1") {
                            return "购买";
                        } else {
                            return "升级";
                        }
                    }
                },
                {title: '会员等级', dataIndex: 'rankLevel', elCls: 'center', width: '15%'},
                {title: '花费', dataIndex: 'spend', elCls: 'center', width: '15%'},
                {
                    title: '邀请者', dataIndex: 'pname', elCls: 'center', width: '10%', renderer: function (value) {
                    if (value == null || value == "") {
                        return "-----";
                    } else {
                        return value;
                    }
                }
                },
                {
                    title: '获得邀请者奖金', dataIndex: 'money', elCls: 'center', width: '10%', renderer: function (value) {
                    if (value == null || value == "") {
                        return "-----";
                    } else {
                        return value;
                    }
                }
                }
            ];

    var store = new Store({
                url: 'loadData',
                autoLoad: true, //自动加载数据
                params: { //配置初始请求的参数
                    length: '10',
                    status: $("#status").val()
                },
                pageSize: 10,	// 配置分页数目
                root: 'list',
                totalProperty: 'total'
            }),
            grid = new Grid.Grid({
                render: '#grid',
                columns: columns,
                loadMask: true, //加载数据时显示屏蔽层
                store: store,
                plugins: [Grid.Plugins.CheckSelection], // 插件形式引入多选表格
                // 底部工具栏
                bbar: {
                    pagingBar: true
                }
            }).render();

    <#---------------------------------------------模糊查询------------------------------------>
    var form = new BUI.Form.HForm({
        srcNode: '#searchForm'
    }).render();

    form.on('beforesubmit', function (ev) {
        //序列化成对象
        var obj = form.serializeToObject();
        obj.start = 0; //返回第一页
        store.load(obj);
        return false;
    });
</script>

</@page.pageBase>
